#include "app_config.h"

#define RE_D  GET_PIN(C,13)
#define RE_CP GET_PIN(G,7)
/*************************rt_thread***************************************/
struct rt_thread scr_refresh_thread;
/*************************rt_stack****************************************/
ALIGN(RT_ALIGN_SIZE)
static rt_uint8_t rt_scr_refresh_thread_stack[2048];
/*************************extern****************************************/
extern struct rt_semaphore sem_temp_available;
extern am_data temp_hum_data;

static lv_style_t indic_style;//指示器样式
static lv_style_t kb_style_rel;
static lv_style_t kb_style_pr;
static lv_style_t kb_style_tgl_rel;
static lv_style_t kb_style_tgl_pr;
static lv_style_t cont_right_style;

lv_theme_t* theme_night;//主题
static lv_obj_t* header;//标题栏
static lv_obj_t* tabview;//tabview
static rt_uint8_t *jpg_sdram = RT_NULL;


static lv_obj_t* cont_right_info;
static lv_obj_t* cont_right_net;
static lv_obj_t* cont_right_modbus;
static lv_obj_t* cont_right_war;
static lv_obj_t* label_time_headr;

static lv_obj_t* tab_page[5];
static lv_obj_t* led_air[8];
static lv_chart_series_t* vol_col_i[4];

static lv_obj_t* key_wifi;

static lv_obj_t* key_modbus;

//static lv_obj_t* title_icon;

static lv_obj_t *ta_ssid;

static lv_obj_t *ta_pwd;

static lv_obj_t *ta_modbus_tcp_ip;

static lv_obj_t *ta_modbus_rtu_dev_air;

static lv_obj_t* sw_wifi;

static lv_obj_t* sw_4g;

static lv_obj_t* sw_first;

static lv_obj_t *roller_baud;

static lv_obj_t *roller_war_v;

static lv_obj_t *roller_war_v1;

static lv_obj_t *roller_war_i;

static lv_obj_t* label_temp;

static lv_obj_t* label_hum;

static lv_obj_t* gauge_temp;

static lv_chart_series_t* ser_dckw;

static lv_chart_series_t* ser_dcssd;

static lv_obj_t* chart_dckw;

static lv_obj_t* chart_dcssd;

static lv_obj_t* led1;

static lv_obj_t* led2;

static lv_obj_t* led3;

static lv_obj_t* led4;

static lv_obj_t* led5;

static lv_obj_t* led6;

static lv_obj_t* led7;

static lv_obj_t* label_va_num;

static lv_obj_t* label_vb_num;

static lv_obj_t* label_vc_num;

static lv_obj_t* label_i_num;

static lv_obj_t* chart_v;

static lv_obj_t* chart_i;

static lv_obj_t* gauge_hum;
const char baud[] = "1200\n2400\n4800\n9600\n14400\n19200\n38400\n115200";
const char v1war[] = "100\n105\n110\n115\n120\n125\n130\n135\n140\n145";
const char vwar[] = "150\n160\n170\n180\n190\n200\n205\n210";
const char iwar[] = "30\n50\n100\n300\n500\n1000";

LV_FONT_DECLARE(FONT_SMG)

rt_uint8_t lv_load_img_bin_from_file(lv_img_dsc_t *image, const char *file_name)
{
	
		int fd;
		int ret;
		int size ;
		struct stat file_sta;
		
		rt_uint32_t header;
		if(file_name == RT_NULL)
		return 1;
	
		fd = open(file_name, O_RDONLY);
		
		if (fd>= 0)
		{
			ret = stat(file_name, &file_sta);
			if(ret == 0)
			{
				jpg_sdram = rt_malloc(file_sta.st_size);
				if(jpg_sdram == RT_NULL)
				{
					rt_kprintf("init JPG buffer failed!\n");
					return 0;
				}
				
				size = read(fd,jpg_sdram,file_sta.st_size);
				
				if(size != file_sta.st_size)
				{
					rt_kprintf("read JPG size failed!\n");
					return 0;
				}
				else
				{
					header =  (uint32_t)jpg_sdram[3] << 24;
					header |= (uint32_t)jpg_sdram[2] << 16;
					header |= (uint32_t)jpg_sdram[1] << 8;
					header |= (uint32_t)jpg_sdram[0];

					image->header.cf = jpg_sdram[0];
					image->header.always_zero = 0;
					image->header.w = (rt_uint16_t)(header >> 10);
					image->header.h = (rt_uint16_t)(header >> 21);
					image->data_size = file_sta.st_size - 4; 
					image->data = jpg_sdram+4;
					close(fd);
				}
				
			}
			else
			{
				rt_kprintf("get JPG sta failed");
			}
		}
		else
		{
			rt_kprintf("font JPG open failed\r\n");
		}
		return 0;
}
void power_off()
{
		rt_pin_write(RE_D,PIN_HIGH);
		rt_pin_write(RE_CP,PIN_HIGH);
		rt_thread_mdelay(100);
		rt_pin_write(RE_CP,PIN_LOW);
}
void power_on()
{
						rt_pin_write(RE_D,PIN_LOW);
						rt_pin_write(RE_CP,PIN_HIGH);
						rt_thread_mdelay(100);
						rt_pin_write(RE_CP,PIN_LOW);
}
static void btn1_event_cb(lv_obj_t * obj, lv_event_t event)
{
	switch (event)
	{ 
		case LV_EVENT_RELEASED:
					power_off();
		break;
		default:
		break;
	}
}

static void btn2_event_cb(lv_obj_t * obj, lv_event_t event)
{
	switch (event)
	{ 
		case LV_EVENT_RELEASED:
power_on();
		break;
		default:
		break;
	}
}
char* list_v_x = "0\n10\n20\n30\n40\n50\n60(S)";
char* list_v_y = "0\n100\n200\n300\n400\n500\n600\n700";
char* list_i_y = "0\n100\n200\n300\n400\n500\n600\n700";
void apk_vol(lv_obj_t* page)
{
	static lv_style_t style_labe;
	lv_style_copy(&style_labe, &lv_style_pretty_color);
	style_labe.text.color = LV_COLOR_WHITE;
	style_labe.text.font = &FONT_SIZE12;

	static lv_style_t style_button_ina;
	lv_style_copy(&style_button_ina, theme_night->style.btn.ina);
	style_button_ina.text.font = &FONT_SIZE12;

	static lv_style_t style_button_pr;
	lv_style_copy(&style_button_pr, theme_night->style.btn.pr);
	style_button_pr.text.font = &FONT_SIZE12;
	style_button_pr.text.color = LV_COLOR_MAKE(0x00,0xFF,0xFF);

	static lv_style_t style_button_rel;
	lv_style_copy(&style_button_rel, theme_night->style.btn.rel);
	style_button_rel.text.font = &FONT_SIZE12;
	

	static lv_style_t style_button_tgl_pr;
	lv_style_copy(&style_button_tgl_pr, theme_night->style.btn.tgl_pr);
	style_button_tgl_pr.text.font = &FONT_SIZE12;
	style_button_pr.text.color = LV_COLOR_MAKE(0x00, 0xFF, 0xFF);

	static lv_style_t style_button_tgl_rel;
	lv_style_copy(&style_button_tgl_rel, theme_night->style.btn.tgl_rel);
	style_button_tgl_rel.text.font = &FONT_SIZE12;
	style_button_pr.text.color = LV_COLOR_MAKE(0x00, 0xFF, 0xFF);

	lv_obj_t* label_va= lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_va, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_va, "A相电压:"); /* 设置文本 */
	lv_obj_align(label_va, NULL, LV_ALIGN_IN_TOP_LEFT, 20,40); /* 设置位置 */

	label_va_num = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_va_num, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_va_num, "220"); /* 设置文本 */
	lv_obj_align(label_va_num, label_va, LV_ALIGN_OUT_RIGHT_MID, 10, 0); /* 设置位置 */

	lv_obj_t* label_va_uint = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_va_uint, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_va_uint, "V"); /* 设置文本 */
	lv_obj_align(label_va_uint, label_va, LV_ALIGN_OUT_RIGHT_MID, 60, 0); /* 设置位置 */

	lv_obj_t* label_vb = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vb, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vb, "B相电压:"); /* 设置文本 */
	lv_obj_align(label_vb, label_va, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); /* 设置位置 */

	label_vb_num = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vb_num, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vb_num, "220"); /* 设置文本 */
	lv_obj_align(label_vb_num, label_vb, LV_ALIGN_OUT_RIGHT_MID, 10, 0); /* 设置位置 */

	lv_obj_t* label_vb_uint = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vb_uint, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vb_uint, "V"); /* 设置文本 */
	lv_obj_align(label_vb_uint, label_vb, LV_ALIGN_OUT_RIGHT_MID, 60, 0); /* 设置位置 */

	lv_obj_t* label_vc = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vc, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vc, "C相电压:"); /* 设置文本 */
	lv_obj_align(label_vc, label_vb, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); /* 设置位置 */

	 label_vc_num = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vc_num, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vc_num, "220"); /* 设置文本 */
	lv_obj_align(label_vc_num, label_vc, LV_ALIGN_OUT_RIGHT_MID, 10, 0); /* 设置位置 */

	lv_obj_t* label_vc_uint = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_vc_uint, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_vc_uint, "V"); /* 设置文本 */
	lv_obj_align(label_vc_uint, label_vc, LV_ALIGN_OUT_RIGHT_MID, 60, 0); /* 设置位置 */

	chart_v = lv_chart_create(page, NULL); /* 创建图表控件 */
	lv_obj_align(chart_v, NULL, LV_ALIGN_IN_TOP_LEFT,240, 40); /* 设置位置 */
	lv_chart_set_point_count(chart_v, 10); /* 设置显示的点数量 */
	lv_chart_set_series_width(chart_v, 2); /* 设置线宽度 */
	//lv_chart_set_series_darking(chart1, LV_OPA_TRANSP);
	lv_chart_set_series_opa(chart_v, LV_OPA_COVER);
	lv_chart_set_range(chart_v, 0, 700); /* 设置范围 0-100 */
	lv_chart_set_div_line_count(chart_v, 8, 10); /* 设置分割线的数量 */
	lv_chart_set_margin(chart_v, 50); /* 设置标注的扩展长度 */
	lv_chart_set_type(chart_v, LV_CHART_TYPE_LINE); /* 显示方式 */
	//lv_chart_set_x_tick_texts(chart1, list_v_x, 5, LV_CHART_AXIS_DRAW_LAST_TICK); /* 设置标注的文本 */
	lv_obj_set_size(chart_v, 500, 140); /* 设置控件尺寸 */
	//lv_chart_set_x_tick_length(chart1, 5, 25); /* 刻度线长度 */
	lv_chart_set_y_tick_texts(chart_v, list_v_y, 1, LV_CHART_AXIS_INVERSE_LABELS_ORDER); /* 设置标注的文本 */
	lv_chart_set_y_tick_length(chart_v, 10, 10); /* 刻度线长度 */
	lv_chart_set_point_count(chart_v, 20);
	
	
	vol_col_i[0] = lv_chart_add_series(chart_v, LV_COLOR_MAKE(0xFF, 0xFF, 0x00));
	vol_col_i[1] = lv_chart_add_series(chart_v, LV_COLOR_MAKE(0x00, 0xFF, 0x00));
	vol_col_i[2] = lv_chart_add_series(chart_v, LV_COLOR_MAKE(0xFF, 0x00, 0x00));
//	lv_chart_set_next(chart1, ser_va, 100);
//	lv_chart_set_next(chart1, ser_va, 150);
//	lv_chart_set_next(chart1, ser_va, 200);
//	lv_chart_set_next(chart1, ser_va, 220);

//	lv_chart_set_next(chart1, ser_vb, 150);
//	lv_chart_set_next(chart1, ser_vb, 200);
//	lv_chart_set_next(chart1, ser_vb, 220);
//	lv_chart_set_next(chart1, ser_vb, 100);

//	lv_chart_set_next(chart1, ser_vc, 200);
//	lv_chart_set_next(chart1, ser_vc, 220);
//	lv_chart_set_next(chart1, ser_vc, 150);
//	lv_chart_set_next(chart1, ser_vc, 100);


	lv_obj_t* label_i = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_i, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_i, "漏电:"); /* 设置文本 */
	lv_obj_align(label_i, label_vc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 40); /* 设置位置 */

	label_i_num = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_i_num, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_i_num, "156"); /* 设置文本 */
	lv_obj_align(label_i_num, label_i, LV_ALIGN_OUT_RIGHT_MID, 10, 0); /* 设置位置 */

	lv_obj_t* label_i_uint = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_i_uint, LV_LABEL_STYLE_MAIN, &style_labe);
	lv_label_set_text(label_i_uint, "mA"); /* 设置文本 */
	lv_obj_align(label_i_uint, label_i, LV_ALIGN_OUT_RIGHT_MID, 50, 0); /* 设置位置 */

	chart_i = lv_chart_create(page, NULL); /* 创建图表控件 */
	lv_obj_align(chart_i, NULL, LV_ALIGN_IN_TOP_LEFT, 240, 240); /* 设置位置 */
	lv_chart_set_point_count(chart_i, 10); /* 设置显示的点数量 */
	lv_chart_set_series_width(chart_i, 2); /* 设置线宽度 */
	//lv_chart_set_series_darking(chart1, LV_OPA_TRANSP);
	lv_chart_set_series_opa(chart_i, LV_OPA_40);
	lv_chart_set_range(chart_i, 0, 700); /* 设置范围 0-100 */
	lv_chart_set_div_line_count(chart_i, 8, 10); /* 设置分割线的数量 */
	lv_chart_set_margin(chart_i, 50); /* 设置标注的扩展长度 */
	lv_chart_set_type(chart_i, LV_CHART_TYPE_AREA); /* 显示方式 */
	//lv_chart_set_x_tick_texts(chart2, list_v_x, 5, LV_CHART_AXIS_DRAW_LAST_TICK); /* 设置标注的文本 */
	lv_obj_set_size(chart_i, 500, 140); /* 设置控件尺寸 */
	//lv_chart_set_x_tick_length(chart2, 5, 25); /* 刻度线长度 */
	lv_chart_set_y_tick_texts(chart_i, list_i_y, 1, LV_CHART_AXIS_INVERSE_LABELS_ORDER); /* 设置标注的文本 */
	lv_chart_set_y_tick_length(chart_i, 10, 10); /* 刻度线长度 */
	lv_chart_set_point_count(chart_i, 20);

	vol_col_i[3] = lv_chart_add_series(chart_i, LV_COLOR_MAKE(0x00, 0xFF, 0xFF));

//	lv_chart_set_next(chart2, ser_i, 100);
//	lv_chart_set_next(chart2, ser_i, 150);
//	lv_chart_set_next(chart2, ser_i, 200);
//	lv_chart_set_next(chart2, ser_i, 220);


	lv_obj_t* btn1 = lv_btn_create(page, NULL); /* 创建按钮 */
	lv_btn_set_style(btn1,LV_BTN_STYLE_INA,			&style_button_ina);
	lv_btn_set_style(btn1, LV_BTN_STYLE_REL,		&style_button_rel);
	lv_btn_set_style(btn1, LV_BTN_STYLE_PR,			&style_button_pr);
	lv_btn_set_style(btn1, LV_BTN_STYLE_TGL_PR,		&style_button_tgl_pr);
	lv_btn_set_style(btn1, LV_BTN_STYLE_TGL_REL,	&style_button_tgl_rel);
	lv_obj_set_event_cb(btn1, btn1_event_cb);
	lv_obj_set_size(btn1,150,30);
	lv_obj_align(btn1, label_i, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20);
	//lv_btn_set_toggle(btn1, true);

	lv_obj_t* label_btn1 = lv_label_create(btn1, NULL); /* 创建 label 控件 */
	lv_label_set_text(label_btn1, "手动断电");
	lv_obj_align(label_btn1, btn1,LV_ALIGN_CENTER,0,0);
	
	lv_obj_t* btn2 = lv_btn_create(page, NULL); /* 创建按钮 */
	lv_btn_set_style(btn2,LV_BTN_STYLE_INA,			&style_button_ina);
	lv_btn_set_style(btn2, LV_BTN_STYLE_REL,		&style_button_rel);
	lv_btn_set_style(btn2, LV_BTN_STYLE_PR,			&style_button_pr);
	lv_btn_set_style(btn2, LV_BTN_STYLE_TGL_PR,		&style_button_tgl_pr);
	lv_btn_set_style(btn2, LV_BTN_STYLE_TGL_REL,	&style_button_tgl_rel);
	lv_obj_set_event_cb(btn2, btn2_event_cb);
	lv_obj_set_size(btn2,150,30);
	lv_obj_align(btn2, btn1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20);
	//lv_btn_set_toggle(btn1, true);

	lv_obj_t* label_btn2 = lv_label_create(btn2, NULL); /* 创建 label 控件 */
	lv_label_set_text(label_btn2, "手动复电");
	lv_obj_align(label_btn2, btn2,LV_ALIGN_CENTER,0,0);
	
	lv_obj_invalidate(label_btn2);
}


lv_point_t line_points[] = { { 400,10 }, { 400, 380 }};
char* list_value_x = "0\n10\n20\n30\n40\n50\n60(T)";
char* list_value_y = "0\n20\n40\n60\n80";
char* list_value_y2 = "-20\n0\n20\n40\n60";
void apk_ph(lv_obj_t* page)
{
	static lv_style_t style_line;
	lv_style_copy(&style_line, theme_night->style.line.decor);
	style_line.line.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	style_line.line.width = 2;
	style_line.line.rounded = 1;
	style_line.line.opa = 100;

	static lv_style_t gf_lable_title_style;
	lv_style_copy(&gf_lable_title_style, theme_night->style.cont);
	gf_lable_title_style.text.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	gf_lable_title_style.text.font = &FONT_SIZE18;

	static lv_style_t select_lable_title_style;
	lv_style_copy(&select_lable_title_style, theme_night->style.cont);
	select_lable_title_style.text.font = &FONT_SIZE12;

	static lv_style_t style_led;
	lv_style_copy(&style_led, &lv_style_pretty_color);
	style_led.body.shadow.width = 3;
	style_led.body.radius = LV_RADIUS_CIRCLE;
	style_led.body.border.width = 1;
	style_led.body.border.opa = LV_OPA_30;
	style_led.body.main_color =  LV_COLOR_MAKE(0x00, 0xff, 0xff);
	style_led.body.grad_color =	 LV_COLOR_MAKE(0x4d, 0xb3, 0xb3);
	style_led.body.border.color = LV_COLOR_MAKE(0x11, 0xee, 0xee);
	style_led.body.shadow.color = LV_COLOR_MAKE(0x11, 0xee, 0xee);

	lv_obj_t* line1 = lv_line_create(page, NULL); /* 创建 line 控件 */
	lv_line_set_style(line1, LV_LINE_STYLE_MAIN, &style_line); /* 设置样式 */
	lv_line_set_points(line1, line_points, 2); /* 设置点阵集 */
//	lv_line_set_y_invert(line1, true);
	lv_line_set_auto_size(line1, true);


	lv_obj_t* label_dc_headr = lv_label_create(page, NULL);
	lv_label_set_style(label_dc_headr, LV_LABEL_STYLE_MAIN, &gf_lable_title_style);
	lv_label_set_text(label_dc_headr, "储能监控");
	lv_obj_align(label_dc_headr, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 0);

	lv_obj_t* label_s1 = lv_label_create(page, NULL);
	lv_label_set_style(label_s1, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s1, "并离网模式");
	lv_obj_align(label_s1, label_dc_headr, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20);

	led1 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led1, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led1,20,20);
	lv_obj_align(led1, label_s1, LV_ALIGN_OUT_LEFT_MID, 200, 0); /* 设置位置 */
	lv_led_on(led1); /* 打开 led */
	
	lv_obj_t* label_s1_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s1_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s1_r, "并网");
	lv_obj_align(label_s1_r, led1, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
	
	
	led2 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led2, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led2,20,20);
	lv_obj_align(led2, led1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_off(led2); /* 打开 led */
	
	lv_obj_t* label_s2_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s2_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s2_r, "离网");
	lv_obj_align(label_s2_r, led2, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	lv_obj_t* label_s2 = lv_label_create(page, NULL);
	lv_label_set_style(label_s2, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s2, "能量调度模式");
	lv_obj_align(label_s2, label_s1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 50);
	
	led3 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led3, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led3,20,20);
	lv_obj_align(led3, led2, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_off(led3); 
	
	lv_obj_t* label_s3_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s3_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s3_r, "交流调度");
	lv_obj_align(label_s3_r, led3, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	led4 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led4, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led4,20,20);
	lv_obj_align(led4, led3, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_on(led4); 
	
	lv_obj_t* label_s4_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s4_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s4_r, "直流调度");
	lv_obj_align(label_s4_r, led4, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	led5 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led5, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led5,20,20);
	lv_obj_align(led5, led4, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_off(led5); 
	
	lv_obj_t* label_s5_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s5_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s5_r, "分支调度");
	lv_obj_align(label_s5_r, led5, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	lv_obj_t* label_s3 = lv_label_create(page, NULL);
	lv_label_set_style(label_s3, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s3, "启动方式");
	lv_obj_align(label_s3, label_s2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 90);
	
	led6 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led6, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led6,20,20);
	lv_obj_align(led6, led5, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_on(led6); 
	
	lv_obj_t* label_s6_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s6_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s6_r, "自动开机");
	lv_obj_align(label_s6_r, led6, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	
	led7 = lv_led_create(page, NULL); /* 创建 led 控件 */
	lv_led_set_style(led7, LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led7,20,20);
	lv_obj_align(led7, led6, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); /* 设置位置 */
	lv_led_off(led7); 
	
	lv_obj_t* label_s7_r = lv_label_create(page, NULL);
	lv_label_set_style(label_s7_r, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_s7_r, "手动开机");
	lv_obj_align(label_s7_r, led7, LV_ALIGN_OUT_RIGHT_MID, 20, 0);	
	
	lv_obj_t* label_bat_headr = lv_label_create(page, NULL);
	lv_label_set_style(label_bat_headr, LV_LABEL_STYLE_MAIN, &gf_lable_title_style);
	lv_label_set_text(label_bat_headr, "电池仓");
	lv_obj_align(label_bat_headr, label_dc_headr, LV_ALIGN_OUT_LEFT_MID, 480, 0);
	
	chart_dckw = lv_chart_create(page, NULL); /* 创建图表控件 */
	lv_obj_align(chart_dckw, label_bat_headr, LV_ALIGN_OUT_BOTTOM_LEFT, 40, 40); /* 设置位置 */
	lv_chart_set_point_count(chart_dckw, 12); /* 设置显示的点数量 */
	lv_chart_set_series_width(chart_dckw, 2); /* 设置线宽度 */
	//lv_chart_set_series_darking(chart1, LV_OPA_TRANSP);
	lv_chart_set_series_opa(chart_dckw, LV_OPA_40);
	lv_chart_set_range(chart_dckw, 0, 100); /* 设置范围 0-100 */
	lv_chart_set_div_line_count(chart_dckw, 4, 9); /* 设置分割线的数量 */
	lv_chart_set_margin(chart_dckw, 50); /* 设置标注的扩展长度 */
	lv_chart_set_type(chart_dckw, LV_CHART_TYPE_AREA); /* 显示方式 */
	lv_chart_set_x_tick_texts(chart_dckw, list_value_x, 5, LV_CHART_AXIS_DRAW_LAST_TICK); /* 设置标注的文本 */
	lv_obj_set_size(chart_dckw, 330, 100); /* 设置控件尺寸 */
	lv_chart_set_x_tick_length(chart_dckw, 5, 25); /* 刻度线长度 */
	lv_chart_set_y_tick_texts(chart_dckw, list_value_y, 1, LV_CHART_AXIS_INVERSE_LABELS_ORDER); /* 设置标注的文本 */
	lv_chart_set_y_tick_length(chart_dckw, 10, 10); /* 刻度线长度 */
	lv_chart_set_point_count(chart_dckw,12);
	ser_dckw = lv_chart_add_series(chart_dckw, LV_COLOR_MAKE(0x00,0xFF,0xFF));
	//lv_chart_init_points(chart1, ser1,50);

	lv_obj_t* label_char1 = lv_label_create(page, NULL);
	lv_label_set_style(label_char1, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_char1, "直流功率(KW)");
	lv_obj_align(label_char1, chart_dckw, LV_ALIGN_OUT_TOP_LEFT, 0, 0);


	chart_dcssd = lv_chart_create(page, NULL); /* 创建图表控件 */
	lv_obj_align(chart_dcssd, chart_dckw, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 60); /* 设置位置 */
	lv_chart_set_point_count(chart_dcssd, 10); /* 设置显示的点数量 */
	lv_chart_set_series_width(chart_dcssd, 2); /* 设置线宽度 */
	lv_chart_set_series_opa(chart_dcssd, LV_OPA_40);
	lv_chart_set_range(chart_dcssd, -20, 80); /* 设置范围 0-100 */
	lv_chart_set_div_line_count(chart_dcssd, 4, 9); /* 设置分割线的数量 */
	lv_chart_set_margin(chart_dcssd, 50); /* 设置标注的扩展长度 */
	lv_chart_set_type(chart_dcssd, LV_CHART_TYPE_AREA); /* 显示方式 */
	lv_chart_set_x_tick_texts(chart_dcssd, list_value_x, 5, LV_CHART_AXIS_DRAW_LAST_TICK); /* 设置标注的文本 */
	lv_obj_set_size(chart_dcssd, 330, 100); /* 设置控件尺寸 */
	lv_chart_set_x_tick_length(chart_dcssd, 5, 25); /* 刻度线长度 */
	lv_chart_set_y_tick_texts(chart_dcssd, list_value_y2, 1, LV_CHART_AXIS_INVERSE_LABELS_ORDER); /* 设置标注的文本 */
	lv_chart_set_y_tick_length(chart_dcssd, 10, 10); /* 刻度线长度 */
	lv_chart_set_point_count(chart_dcssd, 12);
	ser_dcssd = lv_chart_add_series(chart_dcssd, LV_COLOR_MAKE(0x00, 0xFF, 0xFF));
	//lv_chart_init_points(chart2, ser2,50);

	lv_obj_t* label_char2 = lv_label_create(page, NULL);
	lv_label_set_style(label_char2, LV_LABEL_STYLE_MAIN, &select_lable_title_style);
	lv_label_set_text(label_char2, "模组温度(℃)");
	lv_obj_align(label_char2, chart_dcssd, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
}

void apk_home(lv_obj_t* page)
{
	static lv_style_t lable_time_style;
	lv_style_copy(&lable_time_style, theme_night->style.cont);
	lable_time_style.text.font = &FONT_SIZE18;
	lable_time_style.text.color = LV_COLOR_MAKE(0x00,0xff,0x0ff);
	
	lv_obj_t* home_headr = lv_label_create(page, NULL);
	lv_label_set_style(home_headr, LV_LABEL_STYLE_MAIN, &lable_time_style);
	lv_label_set_text(home_headr, "RT-Thread 创新应用设计大赛 \n          -- 综合网关");
	lv_obj_align(home_headr, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
	
	static lv_style_t style_gauge_temp;
	static lv_style_t style_gauge_hum;
	static lv_style_t style_labe;

	lv_style_copy(&style_gauge_temp, &lv_style_pretty_color);
	style_gauge_temp.body.main_color = lv_color_hex(0x00ccff); /* 比例尺开始处的线条颜色 */
	style_gauge_temp.body.grad_color = lv_color_hex(0x00ff00); /* 比例尺末端的线条颜色(与主色的渐变) */
	style_gauge_temp.body.padding.left = 10; /* 行长 */
	style_gauge_temp.body.padding.inner = 1; /* 标签与比例线的距离 */
	style_gauge_temp.body.radius = 10; /* 针原点圆的半径 */
	style_gauge_temp.line.width = 3; /* 线宽 */
	style_gauge_temp.line.color = lv_color_hex(0xff9900); /* 临界值之后的线条颜色 */
	style_gauge_temp.text.color = LV_COLOR_WHITE; /* 文本颜色 */

	lv_style_copy(&style_gauge_hum, &lv_style_pretty_color);
	style_gauge_hum.body.main_color = lv_color_hex(0xff9900); /* 比例尺开始处的线条颜色 */
	style_gauge_hum.body.grad_color = lv_color_hex(0x00ff00); /* 比例尺末端的线条颜色(与主色的渐变) */
	style_gauge_hum.body.padding.left = 10; /* 行长 */
	style_gauge_hum.body.padding.inner = 1; /* 标签与比例线的距离 */
	style_gauge_hum.body.radius = 10; /* 针原点圆的半径 */
	style_gauge_hum.line.width = 3; /* 线宽 */
	style_gauge_hum.line.color = lv_color_hex(0x00ccff); /* 临界值之后的线条颜色 */
	style_gauge_hum.text.color = LV_COLOR_WHITE; /* 文本颜色 */

	lv_style_copy(&style_labe, &lv_style_pretty_color);
	style_labe.text.color = LV_COLOR_WHITE;
	style_labe.text.font = &FONT_SIZE12;

	gauge_temp = lv_gauge_create(page, NULL); /* 创建 gauge 控件 */
	lv_obj_align(gauge_temp, NULL, LV_ALIGN_IN_LEFT_MID, 50, 50); /* 设置位置 */
	lv_gauge_set_range(gauge_temp,-40,80);
	lv_gauge_set_value(gauge_temp, 0, 20); /* 设置值 */
	lv_gauge_set_critical_value(gauge_temp, 60); /* 设置临界值 */
	lv_gauge_set_style(gauge_temp, LV_GAUGE_STYLE_MAIN, &style_gauge_temp); /* 设置样式 */
	lv_gauge_set_scale(gauge_temp, 270, 19, 7); /* 设置刻度和标签 */

	lv_obj_t* label = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_text(label, "温度"); /* 设置文本 */
	lv_obj_align(label, gauge_temp, LV_ALIGN_OUT_TOP_MID, 0, -10); /* 设置位置 */

	label_temp = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_temp,LV_LABEL_STYLE_MAIN,&style_labe);
	//lv_label_set_text(label_temp, "25℃"); /* 设置文本 */
	lv_obj_align(label_temp, gauge_temp, LV_ALIGN_IN_BOTTOM_MID, 0, -20); /* 设置位置 */

	gauge_hum = lv_gauge_create(page, NULL); /* 创建 gauge 控件 */
	lv_obj_align(gauge_hum, NULL, LV_ALIGN_IN_RIGHT_MID, -50, 50); /* 设置位置 */
	lv_gauge_set_range(gauge_hum, 0, 100);
	//lv_gauge_set_value(gauge_hum, 0, 10); /* 设置值 */
	lv_gauge_set_critical_value(gauge_hum, 70); /* 设置临界值 */
	lv_gauge_set_style(gauge_hum, LV_GAUGE_STYLE_MAIN, &style_gauge_hum); /* 设置样式 */
	lv_gauge_set_scale(gauge_hum, 270, 16, 6); /* 设置刻度和标签 */

	label_hum= lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_style(label_hum, LV_LABEL_STYLE_MAIN, &style_labe);
	//lv_label_set_text(label_hum, "50%"); /* 设置文本 */
	lv_obj_align(label_hum, gauge_hum, LV_ALIGN_IN_BOTTOM_MID, 0, -20); /* 设置位置 */

	lv_obj_t* label1 = lv_label_create(page, NULL); /* 创建 label 控件 */
	lv_label_set_text(label1, "湿度"); /* 设置文本 */
	lv_obj_align(label1, gauge_hum, LV_ALIGN_OUT_TOP_MID, 0, -10); /* 设置位置 */
}

void apk_air(lv_obj_t* page)
{
	rt_uint32_t cont_w = 170;
	static lv_style_t style_led;
	lv_style_copy(&style_led, &lv_style_pretty_color);
	style_led.body.shadow.width = 3;
	style_led.body.radius = LV_RADIUS_CIRCLE;
	style_led.body.border.width = 1;
	style_led.body.border.opa = LV_OPA_30;
	style_led.body.main_color =  LV_COLOR_MAKE(0x00, 0xff, 0xff);
	style_led.body.grad_color =	 LV_COLOR_MAKE(0x4d, 0xb3, 0xb3);
	style_led.body.border.color = LV_COLOR_MAKE(0x11, 0xee, 0xee);
	style_led.body.shadow.color = LV_COLOR_MAKE(0x11, 0xee, 0xee);
	
	static lv_style_t lable_title_style;
	lv_style_copy(&lable_title_style, theme_night->style.cont);
	lable_title_style.text.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	lable_title_style.text.font = &FONT_SIZE18;
	
	static lv_style_t cont_lable_title_style;
	lv_style_copy(&cont_lable_title_style, theme_night->style.cont);
	cont_lable_title_style.text.font = &FONT_SIZE12;
	
	
	lv_obj_t* label_air_headr = lv_label_create(page, NULL);
	lv_label_set_style(label_air_headr, LV_LABEL_STYLE_MAIN, &lable_title_style);
	lv_label_set_text(label_air_headr, "中央空调");
	lv_obj_align(label_air_headr, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
	
	
	lv_obj_t* cont_air1= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air1,cont_w,100);
	lv_obj_align(cont_air1, NULL, LV_ALIGN_IN_TOP_LEFT, 30, 100);
	
	lv_obj_t * label_ari1 = lv_label_create(cont_air1, NULL);
	lv_label_set_style(label_ari1,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari1, "营业厅");
	lv_obj_align(label_ari1, cont_air1, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari1_num = lv_label_create(cont_air1, NULL);
	lv_label_set_style(label_ari1_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari1_num, "数量");
	lv_obj_align(label_ari1_num, cont_air1, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari1_num_r = lv_label_create(cont_air1, NULL);
	lv_label_set_style(label_ari1_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari1_num_r, "4");
	lv_obj_align(label_ari1_num_r, cont_air1, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[0] = lv_led_create(cont_air1, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[0], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[0],20,20);
	lv_obj_align(led_air[0], cont_air1, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_on(led_air[0]); 
	
	lv_obj_t* cont_air2= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air2,cont_w,100);
	lv_obj_align(cont_air2, cont_air1, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
	
	lv_obj_t * label_ari2 = lv_label_create(cont_air2, NULL);
	lv_label_set_style(label_ari2,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari2, "业务办理区");
	lv_obj_align(label_ari2, cont_air2, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari2_num = lv_label_create(cont_air2, NULL);
	lv_label_set_style(label_ari2_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari2_num, "数量");
	lv_obj_align(label_ari2_num, cont_air2, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari2_num_r = lv_label_create(cont_air2, NULL);
	lv_label_set_style(label_ari2_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari2_num_r, "1");
	lv_obj_align(label_ari2_num_r, cont_air2, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[1] = lv_led_create(cont_air2, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[1], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[1],20,20);
	lv_obj_align(led_air[1], cont_air2, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[1]); 
	
	lv_obj_t* cont_air3= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air3,cont_w,100);
	lv_obj_align(cont_air3, cont_air2, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
	
	lv_obj_t * label_ari3 = lv_label_create(cont_air3, NULL);
	lv_label_set_style(label_ari3,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari3, "营业班");
	lv_obj_align(label_ari3, cont_air3, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari3_num = lv_label_create(cont_air3, NULL);
	lv_label_set_style(label_ari3_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari3_num, "数量");
	lv_obj_align(label_ari3_num, cont_air3, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari3_num_r = lv_label_create(cont_air3, NULL);
	lv_label_set_style(label_ari3_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari3_num_r, "1");
	lv_obj_align(label_ari3_num_r, cont_air3, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[2] = lv_led_create(cont_air3, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[2], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[2],20,20);
	lv_obj_align(led_air[2], cont_air3, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[2]); 
	
	lv_obj_t* cont_air4= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air4,cont_w,100);
	lv_obj_align(cont_air4, cont_air3, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
	
	lv_obj_t * label_ari4 = lv_label_create(cont_air4, NULL);
	lv_label_set_style(label_ari4,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari4, "更衣室");
	lv_obj_align(label_ari4, cont_air4, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari4_num = lv_label_create(cont_air4, NULL);
	lv_label_set_style(label_ari4_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari4_num, "数量");
	lv_obj_align(label_ari4_num, cont_air4, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari4_num_r = lv_label_create(cont_air4, NULL);
	lv_label_set_style(label_ari4_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari4_num_r, "1");
	lv_obj_align(label_ari4_num_r, cont_air4, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[3] = lv_led_create(cont_air4, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[3], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[3],20,20);
	lv_obj_align(led_air[3], cont_air4, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[3]); 
	
	lv_obj_t* cont_air5= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air5,cont_w,100);
	lv_obj_align(cont_air5, cont_air1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 50);
	
	lv_obj_t * label_ari5 = lv_label_create(cont_air5, NULL);
	lv_label_set_style(label_ari5,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari5, "资料室");
	lv_obj_align(label_ari5, cont_air5, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari5_num = lv_label_create(cont_air5, NULL);
	lv_label_set_style(label_ari5_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari5_num, "数量");
	lv_obj_align(label_ari5_num, cont_air5, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari5_num_r = lv_label_create(cont_air5, NULL);
	lv_label_set_style(label_ari5_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari5_num_r, "1");
	lv_obj_align(label_ari5_num_r, cont_air5, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[4] = lv_led_create(cont_air5, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[4], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[4],20,20);
	lv_obj_align(led_air[4], cont_air5, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[4]);

	lv_obj_t* cont_air6= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air6,cont_w,100);
	lv_obj_align(cont_air6, cont_air2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 50);
	
	lv_obj_t * label_ari6 = lv_label_create(cont_air6, NULL);
	lv_label_set_style(label_ari6,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari6, "自助区");
	lv_obj_align(label_ari6, cont_air6, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari6_num = lv_label_create(cont_air6, NULL);
	lv_label_set_style(label_ari6_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari6_num, "数量");
	lv_obj_align(label_ari6_num, cont_air6, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari6_num_r = lv_label_create(cont_air6, NULL);
	lv_label_set_style(label_ari6_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari6_num_r, "1");
	lv_obj_align(label_ari6_num_r, cont_air6, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[5] = lv_led_create(cont_air6, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[5], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[5],20,20);
	lv_obj_align(led_air[5], cont_air6, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[5]); 
	
	lv_obj_t* cont_air7= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air7,cont_w,100);
	lv_obj_align(cont_air7, cont_air3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 50);
	
	lv_obj_t * label_ari7 = lv_label_create(cont_air7, NULL);
	lv_label_set_style(label_ari7,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari7, "办公室");
	lv_obj_align(label_ari7, cont_air7, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari7_num = lv_label_create(cont_air7, NULL);
	lv_label_set_style(label_ari7_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari7_num, "数量");
	lv_obj_align(label_ari7_num, cont_air7, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari7_num_r = lv_label_create(cont_air7, NULL);
	lv_label_set_style(label_ari7_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari7_num_r, "1");
	lv_obj_align(label_ari7_num_r, cont_air7, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[6] = lv_led_create(cont_air7, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[6], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[6],20,20);
	lv_obj_align(led_air[6], cont_air7, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_off(led_air[6]); 
	
	lv_obj_t* cont_air8= lv_cont_create(page, NULL);
	lv_obj_set_size(cont_air8,cont_w,100);
	lv_obj_align(cont_air8, cont_air4, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 50);
	
	lv_obj_t * label_ari8 = lv_label_create(cont_air8, NULL);
	lv_label_set_style(label_ari8,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari8, "值班室");
	lv_obj_align(label_ari8, cont_air8, LV_ALIGN_IN_TOP_LEFT, 10, 10);	
	
	lv_obj_t * label_ari8_num = lv_label_create(cont_air8, NULL);
	lv_label_set_style(label_ari8_num,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari8_num, "数量");
	lv_obj_align(label_ari8_num, cont_air8, LV_ALIGN_IN_TOP_LEFT, 10, 50);	
	
	lv_obj_t * label_ari8_num_r = lv_label_create(cont_air8, NULL);
	lv_label_set_style(label_ari8_num_r,LV_LABEL_STYLE_MAIN,&cont_lable_title_style);
	lv_label_set_text(label_ari8_num_r, "1");
	lv_obj_align(label_ari8_num_r, cont_air8, LV_ALIGN_IN_TOP_RIGHT, -10, 50);	
	
	led_air[7] = lv_led_create(cont_air8, NULL); /* 创建 led 控件 */
	lv_led_set_style(led_air[7], LV_LED_STYLE_MAIN, &style_led); /* 设置样式 */
	lv_obj_set_size(led_air[7],20,20);
	lv_obj_align(led_air[7], cont_air8, LV_ALIGN_IN_TOP_RIGHT, -10, 10); /* 设置位置 */
	lv_led_on(led_air[7]); 
	
	
}

static void header_create(void)
{
	time_t cur_time;
	struct tm *info;
	char local_time[40] = {0};
	
	static lv_style_t header_style;
	lv_style_copy(&header_style,theme_night->style.cont);
	header_style.body.border.width = 0;
	header_style.body.radius = 0;
	
	header = lv_cont_create(lv_disp_get_scr_act(NULL), NULL);
	lv_obj_set_height(header,20);
	lv_obj_set_width(header, lv_disp_get_hor_res(NULL));
	lv_cont_set_style(header, LV_CONT_STYLE_MAIN, &header_style);
	
	lv_obj_t* title = lv_label_create(header, NULL);
	lv_label_set_text(title, "RT-Thread创新应用设计大赛");
	lv_obj_align(title, NULL, LV_ALIGN_IN_LEFT_MID, LV_DPI / 10, 0);
	
	lv_cont_set_fit2(header, LV_FIT_NONE, LV_FIT_TIGHT);   /*Let the height set automatically*/
	lv_obj_set_pos(header, 0, 0);
	
	static lv_style_t lable_time_style;
	lv_style_copy(&lable_time_style, theme_night->style.cont);
	lable_time_style.text.font = &FONT_SMG;
	
	cur_time = time(RT_NULL);
	info = localtime(&cur_time);//timer 的值被分解为 tm 结构，并用本地时区表示。
	strftime(local_time, 40, "%T ",info);

	label_time_headr = lv_label_create(header, NULL);
	lv_label_set_text(label_time_headr, local_time);
	lv_obj_align(label_time_headr, NULL, LV_ALIGN_IN_RIGHT_MID, -LV_DPI / 10, 0);

}
static void keyboard_event_cb(lv_obj_t * obj, lv_event_t event)
{
	lv_kb_def_event_cb(key_wifi, event);
	if (event == LV_EVENT_APPLY || event == LV_EVENT_CANCEL)
	{
		lv_ta_set_cursor_type(ta_ssid, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
		lv_ta_set_cursor_type(ta_pwd, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
		lv_obj_del(key_wifi);
		key_wifi = NULL;
	}
}

static void keyboard_modubs_event_cb(lv_obj_t * obj, lv_event_t event)
{
	lv_kb_def_event_cb(key_modbus, event);
	if (event == LV_EVENT_APPLY || event == LV_EVENT_CANCEL)
	{
		lv_ta_set_cursor_type(ta_modbus_tcp_ip, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
		lv_ta_set_cursor_type(ta_modbus_rtu_dev_air, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
		lv_obj_del(key_modbus);
		key_modbus = NULL;
	}
}

static void sw_event_cb(lv_obj_t * obj, lv_event_t event)
{
	if(event == LV_EVENT_VALUE_CHANGED)
	{
			if(obj == sw_first)
			{
				if(lv_sw_get_state(sw_first) == true)
				{
					if(lv_sw_get_state(sw_4g) == false)
					{
							lv_sw_on(sw_4g,LV_ANIM_ON);
					}
				}
				return;
			}
			if(obj == sw_4g)
			{
				if(lv_sw_get_state(sw_4g) == false)
				{
					if(lv_sw_get_state(sw_first) == true)
					{
							lv_sw_off(sw_first,LV_ANIM_ON);
					}
				}
				return;
			}
			
//			if(obj == sw_wifi)
//			{
//				if(lv_sw_get_state(sw_wifi) == true)
//				{
//					title_icon= lv_label_create(header, NULL);
//					lv_label_set_text(title_icon,"\xef\x82\x9e");
//					lv_obj_align(title_icon, NULL, LV_ALIGN_IN_RIGHT_MID, -LV_DPI / 10, 0);
//				}
//				else
//				{
//					if(title_icon != NULL)
//					{
//						lv_obj_del(title_icon);
//					}
//				}
//				return;
//			}
			
	}
}
static void ta_event_cb(lv_obj_t * obj, lv_event_t event)
{
	if (event == LV_EVENT_CLICKED)
	{
		if((obj == ta_ssid) || (obj == ta_pwd))
		{
			/* 创建键盘 */
				if (key_wifi == NULL)
				{
					key_wifi = lv_kb_create(lv_disp_get_scr_act(NULL), NULL);
					lv_kb_set_cursor_manage(key_wifi, true);
					lv_kb_set_style(key_wifi, LV_KB_STYLE_BG, &lv_style_transp_tight);
					lv_kb_set_style(key_wifi, LV_KB_STYLE_BTN_REL, 		 &kb_style_rel);
					lv_kb_set_style(key_wifi, LV_KB_STYLE_BTN_PR, 		 &kb_style_pr);
					lv_kb_set_style(key_wifi, LV_KB_STYLE_BTN_TGL_REL, &kb_style_tgl_rel);
					lv_kb_set_style(key_wifi, LV_KB_STYLE_BTN_TGL_PR,  &kb_style_tgl_pr);
					lv_obj_set_pos(key_wifi,200,280);
					lv_obj_set_size(key_wifi,600,200);
					lv_obj_set_event_cb(key_wifi, keyboard_event_cb);
					lv_kb_set_ta(key_wifi, obj);
				} 
				else
				{
					lv_kb_set_ta(key_wifi, obj);
				}
				return ;
		}
		
		if((obj == ta_modbus_tcp_ip) || (obj == ta_modbus_rtu_dev_air))
		{
			if(key_modbus == NULL)
			{
				key_modbus = lv_kb_create(lv_disp_get_scr_act(NULL), NULL);
				lv_kb_set_cursor_manage(key_modbus, true);
				lv_kb_set_mode(key_modbus, LV_KB_MODE_NUM);
				lv_kb_set_style(key_modbus, LV_KB_STYLE_BG, &lv_style_transp_tight);
				lv_kb_set_style(key_modbus, LV_KB_STYLE_BTN_REL, 		 &kb_style_rel);
				lv_kb_set_style(key_modbus, LV_KB_STYLE_BTN_PR, 		 &kb_style_pr);
				lv_kb_set_style(key_modbus, LV_KB_STYLE_BTN_TGL_REL, &kb_style_tgl_rel);
				lv_kb_set_style(key_modbus, LV_KB_STYLE_BTN_TGL_PR,  &kb_style_tgl_pr);
				lv_obj_set_pos(key_modbus,500,200);
				lv_obj_set_size(key_modbus,300,250); 
				lv_obj_set_event_cb(key_modbus, keyboard_modubs_event_cb);
				lv_kb_set_ta(key_modbus, obj);
			}
			else
			{
				lv_kb_set_ta(key_modbus, obj);
			}
		}
	}
}

void war_cont()
{
	cont_right_war = lv_cont_create(tab_page[4], NULL);
	lv_cont_set_style(cont_right_war, LV_CONT_STYLE_MAIN, &cont_right_style);
	lv_obj_set_size(cont_right_war, lv_disp_get_hor_res(NULL) / 4 * 3, lv_obj_get_height(tab_page[4]));
	lv_obj_set_pos(cont_right_war,lv_disp_get_hor_res(NULL) / 4,0);
	
	lv_obj_t* sw_war_v = lv_sw_create(cont_right_war,NULL);
	lv_sw_set_style(sw_war_v,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_war_v, NULL, LV_ALIGN_IN_TOP_RIGHT, -50, 10);
	lv_sw_set_anim_time(sw_war_v, 100); 
	
	lv_obj_t* label_war_v = lv_label_create(cont_right_war,NULL);
	lv_obj_align(label_war_v, NULL, LV_ALIGN_IN_TOP_LEFT, 50, 10);
	lv_label_set_text(label_war_v,"\xef\x81\x96" "  低电压跳闸");
	
	lv_obj_t* sw_war_v1 = lv_sw_create(cont_right_war,NULL);
	lv_sw_set_style(sw_war_v1,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_war_v1, sw_war_v, LV_ALIGN_IN_TOP_RIGHT,0, 60);
	lv_sw_set_anim_time(sw_war_v1, 100); 
	
	lv_obj_t* label_war_v1 = lv_label_create(cont_right_war,NULL);
	lv_obj_align(label_war_v1, label_war_v, LV_ALIGN_IN_TOP_LEFT, 0, 60);
	lv_label_set_text(label_war_v1,"\xef\x81\x97" "  缺相跳闸");
	
	lv_obj_t* sw_war_i = lv_sw_create(cont_right_war,NULL);
	lv_sw_set_style(sw_war_i,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_war_i, sw_war_v1, LV_ALIGN_IN_TOP_RIGHT,0, 60);
	lv_sw_set_anim_time(sw_war_i, 100); 
	
	lv_obj_t* label_war_i = lv_label_create(cont_right_war,NULL);
	lv_obj_align(label_war_i, label_war_v1, LV_ALIGN_IN_TOP_LEFT, 0, 60);
	lv_label_set_text(label_war_i,"\xef\x83\xA4" "  漏电超限跳闸");
	
	roller_war_v = lv_roller_create(cont_right_war, NULL);
	lv_obj_align(roller_war_v,label_war_i,LV_ALIGN_OUT_BOTTOM_LEFT,0,60);
	lv_roller_set_options(roller_war_v,vwar,LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_fix_width(roller_war_v, 150);//宽度
	lv_roller_set_visible_row_count(roller_war_v, 3);//显示行数
	lv_roller_set_selected(roller_war_v, 3, true);
	
	lv_obj_t * label_v = lv_label_create(cont_right_war, NULL);
	lv_label_set_text(label_v, "低电压:");
	lv_roller_set_anim_time(label_v,300);
	lv_obj_align(label_v, roller_war_v, LV_ALIGN_OUT_TOP_LEFT, 0, 0);	

	roller_war_v1 = lv_roller_create(cont_right_war, NULL);
	lv_obj_align(roller_war_v1,roller_war_v,LV_ALIGN_OUT_RIGHT_MID,25,0);
	lv_roller_set_options(roller_war_v1,v1war,LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_fix_width(roller_war_v1, 150);//宽度
	lv_roller_set_visible_row_count(roller_war_v1, 3);//显示行数
	lv_roller_set_selected(roller_war_v1, 3, true);
	
	lv_obj_t * label_v1 = lv_label_create(cont_right_war, NULL);
	lv_label_set_text(label_v1, "缺相电压:");
	lv_roller_set_anim_time(label_v1,300);
	lv_obj_align(label_v1, roller_war_v1, LV_ALIGN_OUT_TOP_LEFT, 0, 0);	
	
	roller_war_i = lv_roller_create(cont_right_war, NULL);
	lv_obj_align(roller_war_i,roller_war_v1,LV_ALIGN_OUT_RIGHT_MID,25,0);
	lv_roller_set_options(roller_war_i,iwar,LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_fix_width(roller_war_i, 150);//宽度
	lv_roller_set_visible_row_count(roller_war_i, 3);//显示行数
	lv_roller_set_selected(roller_war_i, 3, true);
	
	lv_obj_t * label_i = lv_label_create(cont_right_war, NULL);
	lv_label_set_text(label_i, "漏电超限值:");
	lv_roller_set_anim_time(label_i,300);
	lv_obj_align(label_i, roller_war_i, LV_ALIGN_OUT_TOP_LEFT, 0, 0);	

}

void modbus_cont()
{
	cont_right_modbus = lv_cont_create(tab_page[4], NULL);
	lv_cont_set_style(cont_right_modbus, LV_CONT_STYLE_MAIN, &cont_right_style);
	lv_obj_set_size(cont_right_modbus, lv_disp_get_hor_res(NULL) / 4 * 3, lv_obj_get_height(tab_page[4]));
	lv_obj_set_pos(cont_right_modbus,lv_disp_get_hor_res(NULL) / 4,0);
	
	static lv_style_t modbus_lable_title_style;
	lv_style_copy(&modbus_lable_title_style, theme_night->style.cont);
	modbus_lable_title_style.text.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	modbus_lable_title_style.text.font = &lv_font_roboto_28;
	
	lv_obj_t * label_modbus_headr = lv_label_create(cont_right_modbus, NULL);
	lv_label_set_style(label_modbus_headr,LV_LABEL_STYLE_MAIN,&modbus_lable_title_style);
	lv_label_set_text(label_modbus_headr,"MODBUS-TCP");
	lv_obj_align(label_modbus_headr, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
		
		
	ta_modbus_tcp_ip = lv_ta_create(cont_right_modbus, NULL);
	lv_ta_set_text(ta_modbus_tcp_ip, "192.168.1.110.522");
	lv_ta_set_cursor_type(ta_modbus_tcp_ip, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
	lv_ta_set_one_line(ta_modbus_tcp_ip, true); /* 单行模式 */
	lv_obj_set_width(ta_modbus_tcp_ip, 500); /* 宽度 */
	lv_ta_set_text_align(ta_modbus_tcp_ip, LV_LABEL_ALIGN_CENTER);//居中对齐
	lv_obj_align(ta_modbus_tcp_ip,NULL,LV_ALIGN_IN_TOP_LEFT,50,100);
	lv_obj_set_event_cb(ta_modbus_tcp_ip, ta_event_cb); /* 设置事件回调函数 */
	lv_ta_set_max_length(ta_modbus_tcp_ip, 20);
	lv_obj_t * label_modbus_tcp_ip = lv_label_create(cont_right_modbus, NULL);
	lv_label_set_text(label_modbus_tcp_ip, "服务器地址+端口号:(端口号以\'.\'分开)");
	lv_obj_align(label_modbus_tcp_ip, ta_modbus_tcp_ip, LV_ALIGN_OUT_TOP_LEFT, 0, 0);		
	

	lv_obj_t * label_modbus_rtu = lv_label_create(cont_right_modbus, NULL);
	lv_label_set_style(label_modbus_rtu,LV_LABEL_STYLE_MAIN,&modbus_lable_title_style);
	lv_label_set_text(label_modbus_rtu,"MODBUS-RTU");
	lv_obj_align(label_modbus_rtu, ta_modbus_tcp_ip, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
	
	ta_modbus_rtu_dev_air = lv_ta_create(cont_right_modbus, NULL);
	lv_ta_set_text(ta_modbus_rtu_dev_air, "1");
	lv_ta_set_cursor_type(ta_modbus_rtu_dev_air, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
	lv_ta_set_one_line(ta_modbus_rtu_dev_air, true); /* 单行模式 */
	lv_obj_set_width(ta_modbus_rtu_dev_air, 200); /* 宽度 */
	lv_ta_set_text_align(ta_modbus_rtu_dev_air, LV_LABEL_ALIGN_CENTER);//居中对齐
	lv_obj_align(ta_modbus_rtu_dev_air,NULL,LV_ALIGN_IN_TOP_LEFT,50,270);
	lv_obj_set_event_cb(ta_modbus_rtu_dev_air, ta_event_cb); /* 设置事件回调函数 */
	lv_ta_set_max_length(ta_modbus_rtu_dev_air, 3);
	
	lv_obj_t * label_modbus_rtu_dev_air = lv_label_create(cont_right_modbus, NULL);
	lv_label_set_text(label_modbus_rtu_dev_air, "中央空调控制器地址:");
	lv_obj_align(label_modbus_rtu_dev_air, ta_modbus_rtu_dev_air, LV_ALIGN_OUT_TOP_LEFT, 0, 0);	
	
	
	
	roller_baud = lv_roller_create(cont_right_modbus, NULL);
	lv_obj_align(roller_baud,ta_modbus_rtu_dev_air,LV_ALIGN_OUT_RIGHT_TOP,100,0);
	lv_roller_set_options(roller_baud,baud,LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_fix_width(roller_baud, 200);//宽度
	lv_roller_set_visible_row_count(roller_baud, 3);//显示行数
	//lv_obj_set_event_cb(roller_year, roller_event_cb);//设置事件回调函数 
	lv_roller_set_selected(roller_baud, 3, true);
	
	lv_obj_t * label_modbus_baud = lv_label_create(cont_right_modbus, NULL);
	lv_label_set_text(label_modbus_baud, "波特率:");
	lv_roller_set_anim_time(label_modbus_baud,300);
	lv_obj_align(label_modbus_baud, roller_baud, LV_ALIGN_OUT_TOP_LEFT, 0, 0);		
}



void net_cont()
{
	cont_right_net = lv_cont_create(tab_page[4], NULL);
	lv_cont_set_style(cont_right_net, LV_CONT_STYLE_MAIN, &cont_right_style);
	lv_obj_set_size(cont_right_net, lv_disp_get_hor_res(NULL) / 4 * 3, lv_obj_get_height(tab_page[4]));
	lv_obj_set_pos(cont_right_net,lv_disp_get_hor_res(NULL) / 4,0);
	
	lv_style_copy(&kb_style_rel,theme_night->style.kb.btn.rel);
	kb_style_rel.text.font = &lv_font_roboto_22;
	lv_style_copy(&kb_style_pr,theme_night->style.kb.btn.pr);
	kb_style_pr.text.font = &lv_font_roboto_22;
	kb_style_pr.text.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	lv_style_copy(&kb_style_tgl_rel,theme_night->style.kb.btn.tgl_rel);
	kb_style_tgl_rel.text.font = &lv_font_roboto_22;
	lv_style_copy(&kb_style_tgl_pr,theme_night->style.kb.btn.tgl_pr);
	kb_style_tgl_pr.text.font = &lv_font_roboto_22;
	
	sw_wifi = lv_sw_create(cont_right_net,NULL);
	lv_sw_set_style(sw_wifi,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_wifi, NULL, LV_ALIGN_IN_TOP_RIGHT, -50, 10);
	lv_sw_set_anim_time(sw_wifi, 100); 
	//lv_obj_set_event_cb(sw_wifi, sw_event_cb_wifi); 
	lv_obj_t* label_wifi = lv_label_create(cont_right_net,NULL);
	lv_obj_align(label_wifi, NULL, LV_ALIGN_IN_TOP_LEFT, 50, 10);
	lv_label_set_text(label_wifi,"\xef\x82\x9e" "  无线局域网");

	ta_ssid = lv_ta_create(cont_right_net, NULL);
	lv_ta_set_text(ta_ssid, "njytt");
	lv_ta_set_cursor_type(ta_ssid, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); 
	lv_ta_set_one_line(ta_ssid, true); /* 单行模式 */
	lv_obj_set_width(ta_ssid, 500); /* 宽度 */
	lv_obj_align(ta_ssid,label_wifi,LV_ALIGN_OUT_BOTTOM_LEFT,0,40);
	lv_obj_set_event_cb(ta_ssid, ta_event_cb); /* 设置事件回调函数 */
	lv_ta_set_max_length(ta_ssid, 200);
	lv_obj_t * label_ssid = lv_label_create(cont_right_net, NULL);
	lv_label_set_text(label_ssid, "网络:");
	lv_obj_align(label_ssid, ta_ssid, LV_ALIGN_OUT_TOP_LEFT, 0, 0);

	
	ta_pwd = lv_ta_create(cont_right_net, NULL);
	lv_ta_set_text(ta_pwd, "1qaz2wsx!");
	lv_ta_set_one_line(ta_pwd, true);
	lv_obj_set_width(ta_pwd, 500);
	lv_ta_set_cursor_type(ta_pwd, LV_CURSOR_LINE | LV_CURSOR_HIDDEN); /* 临时隐藏光标,选择后再显示 */
	lv_obj_align(ta_pwd, ta_ssid, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
	lv_ta_set_pwd_mode(ta_pwd, true); /* 设置为密文模式 */
	lv_ta_set_max_length(ta_pwd, 20);
	lv_ta_set_pwd_show_time(ta_pwd, 10); /* 设置密码可以查看的最长时间,过了这个时间以后变成*号 */
	lv_obj_t * label_pwd = lv_label_create(cont_right_net, NULL);
	lv_label_set_text(label_pwd, "密码:");
	lv_obj_align(label_pwd, ta_pwd, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
	lv_obj_set_event_cb(ta_pwd, ta_event_cb);
	
	sw_4g = lv_sw_create(cont_right_net,NULL);
	lv_sw_set_style(sw_4g,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_4g, ta_pwd, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 40);
	lv_obj_set_event_cb(sw_4g,sw_event_cb);
	lv_sw_set_anim_time(sw_4g, 100); 
	lv_obj_t* label_4g = lv_label_create(cont_right_net,NULL);
	lv_obj_align(label_4g, ta_pwd, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 40);
	lv_label_set_text(label_4g,"\xef\x80\x92" "  4G网络");

	sw_first = lv_sw_create(cont_right_net,NULL);
	lv_sw_set_style(sw_first,LV_SW_STYLE_INDIC,&indic_style);
	lv_obj_align(sw_first, sw_4g, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 40);
	lv_sw_set_anim_time(sw_first, 100); 
	
	lv_obj_t* label_first = lv_label_create(cont_right_net,NULL);
	lv_obj_align(label_first, label_4g, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 40);
	lv_label_set_text(label_first,"\xef\x83\xac" "  移动网络优先(默认WIFI优先)");
	
	lv_obj_set_event_cb(sw_first,sw_event_cb);
	
}




void about_cont()
{
	cont_right_info = lv_cont_create(tab_page[4], NULL);
	lv_cont_set_style(cont_right_info, LV_CONT_STYLE_MAIN, &cont_right_style);
	lv_obj_set_size(cont_right_info, lv_disp_get_hor_res(NULL) / 4 * 3, lv_obj_get_height(tab_page[4]));
	lv_obj_set_pos(cont_right_info,lv_disp_get_hor_res(NULL) / 4,0);
	
	static lv_style_t child_lable_title_style;
	lv_style_copy(&child_lable_title_style, theme_night->style.cont);
	child_lable_title_style.text.font = &lv_font_roboto_28;
	
	static lv_style_t child_lable_txt_style;
	lv_style_copy(&child_lable_txt_style, theme_night->style.cont);
	child_lable_txt_style.text.font = &lv_font_roboto_22;
	child_lable_txt_style.text.color = LV_COLOR_MAKE(0x00, 0xff, 0xff);
	
	static lv_style_t child_lable_icon_style;
	lv_style_copy(&child_lable_icon_style, theme_night->style.cont);
	child_lable_icon_style.text.font = &FONT_SIZE12;
	child_lable_icon_style.text.color = LV_COLOR_MAKE(0x4A, 0x70, 0x8B);
	
	static lv_img_dsc_t rtt_logo;
	lv_load_img_bin_from_file(&rtt_logo,"/JPG/RTT_LOGO.bin"); 
	lv_obj_t *img_rtt = lv_img_create(cont_right_info,NULL);
	lv_img_set_src(img_rtt,&rtt_logo);                                     
	lv_obj_align(img_rtt, cont_right_info, LV_ALIGN_IN_TOP_MID, 0, 10);
	
	static lv_img_dsc_t ic_logo;
	lv_load_img_bin_from_file(&ic_logo,"/JPG/IC_LOGO.bin"); 
	lv_obj_t *img_ic = lv_img_create(cont_right_info,NULL);
	lv_img_set_src(img_ic,&ic_logo);                  
	lv_obj_align(img_ic, cont_right_info, LV_ALIGN_IN_TOP_MID, 0, rtt_logo.header.h+20);
	
	lv_obj_t* cont_child1 = lv_cont_create(cont_right_info, NULL);
	lv_obj_set_size(cont_child1,250,90);
	lv_obj_set_pos(cont_child1,45,rtt_logo.header.h+ic_logo.header.h+40);
	
	lv_obj_t * label_rtos = lv_label_create(cont_child1, NULL);
	lv_label_set_style(label_rtos,LV_LABEL_STYLE_MAIN,&child_lable_title_style);
	lv_label_set_text(label_rtos, "RTOS");
	lv_obj_align(label_rtos, cont_child1, LV_ALIGN_IN_TOP_LEFT, 30, 10);	
	
	lv_obj_t * label_rtos_txt = lv_label_create(cont_child1, NULL);
	lv_label_set_style(label_rtos_txt,LV_LABEL_STYLE_MAIN,&child_lable_txt_style);
	lv_label_set_text(label_rtos_txt, "RT-Thread");
	lv_obj_align(label_rtos_txt, cont_child1, LV_ALIGN_IN_LEFT_MID, 70, 20);	
	
	lv_obj_t * label_rtos_icon = lv_label_create(cont_child1, NULL);
	lv_label_set_style(label_rtos_icon,LV_LABEL_STYLE_MAIN,&child_lable_icon_style);
	lv_label_set_text(label_rtos_icon, "\xef\x80\x89");
	lv_obj_align(label_rtos_icon, cont_child1, LV_ALIGN_IN_TOP_RIGHT, -10, 0);	
	
	lv_obj_t* cont_child2 = lv_cont_create(cont_right_info, NULL);
	lv_obj_set_size(cont_child2,250,90);
	lv_obj_set_pos(cont_child2,305,rtt_logo.header.h+ic_logo.header.h+40);
	
	lv_obj_t * label_gui = lv_label_create(cont_child2, NULL);
	lv_label_set_style(label_gui,LV_LABEL_STYLE_MAIN,&child_lable_title_style);
	lv_label_set_text(label_gui, "GUI");
	lv_obj_align(label_gui, cont_child2, LV_ALIGN_IN_TOP_LEFT, 30, 10);	
	
	lv_obj_t * label_gui_txt = lv_label_create(cont_child2, NULL);
	lv_label_set_style(label_gui_txt,LV_LABEL_STYLE_MAIN,&child_lable_txt_style);
	lv_label_set_text(label_gui_txt, "LittlevGL");
	lv_obj_align(label_gui_txt, cont_child2, LV_ALIGN_IN_LEFT_MID, 70, 20);	
	
	lv_obj_t * label_gui_icon = lv_label_create(cont_child2, NULL);
	lv_label_set_style(label_gui_icon,LV_LABEL_STYLE_MAIN,&child_lable_icon_style);
	lv_label_set_text(label_gui_icon, "\xef\x84\x88");
	lv_obj_align(label_gui_icon, cont_child2, LV_ALIGN_IN_TOP_RIGHT, -10, 0);
	
	lv_obj_t* cont_child3 = lv_cont_create(cont_right_info, NULL);
	lv_obj_set_size(cont_child3,250,90);
	lv_obj_set_pos(cont_child3,45,rtt_logo.header.h+ic_logo.header.h+140);
	
	lv_obj_t * label_mcu = lv_label_create(cont_child3, NULL);
	lv_label_set_style(label_mcu,LV_LABEL_STYLE_MAIN,&child_lable_title_style);
	lv_label_set_text(label_mcu, "MCU");
	lv_obj_align(label_mcu, cont_child3, LV_ALIGN_IN_TOP_LEFT, 30, 10);	
	
	lv_obj_t * label_mcu_txt = lv_label_create(cont_child3, NULL);
	lv_label_set_style(label_mcu_txt,LV_LABEL_STYLE_MAIN,&child_lable_txt_style);
	lv_label_set_text(label_mcu_txt, "STM32F767");
	lv_obj_align(label_mcu_txt, cont_child3, LV_ALIGN_IN_LEFT_MID, 70, 20);	
	
	lv_obj_t * label_mcu_icon = lv_label_create(cont_child3, NULL);
	lv_label_set_style(label_mcu_icon,LV_LABEL_STYLE_MAIN,&child_lable_icon_style);
	lv_label_set_text(label_mcu_icon, "\xef\x83\xa4");
	lv_obj_align(label_mcu_icon, cont_child3, LV_ALIGN_IN_TOP_RIGHT, -10, 0);			
	
	
	lv_obj_t* cont_child4 = lv_cont_create(cont_right_info, NULL);
	lv_obj_set_size(cont_child4,250,90);
	lv_obj_set_pos(cont_child4,305,rtt_logo.header.h+ic_logo.header.h+140);//Author
	
	lv_obj_t * label_author = lv_label_create(cont_child4, NULL);
	lv_label_set_style(label_author,LV_LABEL_STYLE_MAIN,&child_lable_title_style);
	lv_label_set_text(label_author, "AUTHOR");
	lv_obj_align(label_author, cont_child4, LV_ALIGN_IN_TOP_LEFT, 30, 10);	
	
	lv_obj_t * label_author_txt = lv_label_create(cont_child4, NULL);
	lv_label_set_style(label_author_txt,LV_LABEL_STYLE_MAIN,&child_lable_txt_style);
	lv_label_set_text(label_author_txt, "bloody41760");
	lv_obj_align(label_author_txt, cont_child4, LV_ALIGN_IN_LEFT_MID, 70, 20);	
	
	lv_obj_t * label_author_icon = lv_label_create(cont_child4, NULL);
	lv_label_set_style(label_author_icon,LV_LABEL_STYLE_MAIN,&child_lable_icon_style);
	lv_label_set_text(label_author_icon, "\xef\x80\x87");
	lv_obj_align(label_author_icon, cont_child4, LV_ALIGN_IN_TOP_RIGHT, -10, 0);		
}



static void btnm_cb_event_handler(lv_obj_t * cb, lv_event_t event)
{
	if(event == LV_EVENT_VALUE_CHANGED)
	{
		lv_obj_set_hidden(cont_right_info,true);
		lv_obj_set_hidden(cont_right_net,true);
		lv_obj_set_hidden(cont_right_modbus,true);
		lv_obj_set_hidden(cont_right_war,true);
		switch(lv_btnm_get_active_btn(cb))
		{
			case 0:
						lv_obj_set_hidden(cont_right_net,false);
				break;
			case 1:
						lv_obj_set_hidden(cont_right_modbus,false);
				break;
			case 2:
						lv_obj_set_hidden(cont_right_war,false);
				break;
			case 3:
						lv_obj_set_hidden(cont_right_info,false);
				break;
			default:
						
				break;
		}
	}
}

void set_page(void)
{
	/* define left style */
	static lv_style_t cont_left_style;

	lv_style_copy(&cont_left_style, theme_night->style.cont);
	cont_left_style.body.border.width = 0;
	cont_left_style.body.radius = 0;

	//定义左边栏cont
	lv_obj_t* cont_left = lv_cont_create(tab_page[4], NULL);
	lv_cont_set_style(cont_left, LV_CONT_STYLE_MAIN, &cont_left_style);
	lv_obj_set_size(cont_left, lv_disp_get_hor_res(NULL) / 4, lv_obj_get_height(tab_page[4]));
	lv_obj_set_pos(cont_left,0,0);
	
	lv_style_copy(&cont_right_style, theme_night->style.bg);
	cont_right_style.body.border.width = 0;
	cont_right_style.body.radius = 0;
	cont_right_style.body.opa = 0;
	cont_right_style.body.main_color = LV_COLOR_MAKE(0x16, 0x19, 0x18);
	cont_right_style.body.grad_color = LV_COLOR_MAKE(0x44, 0x4c, 0x4b);
	cont_right_style.body.border.width = 0;
	cont_right_style.text.color = LV_COLOR_WHITE;//字体颜色
	cont_right_style.text.font = &FONT_SIZE12;
	
	static lv_img_dsc_t image_logo;
	lv_load_img_bin_from_file(&image_logo,"/JPG/LOGO_SELF.bin"); 
	lv_obj_t *img_head = lv_img_create(cont_left,NULL);
	lv_img_set_src(img_head,&image_logo);                                     
	lv_obj_set_pos(img_head, 50, 15);
	lv_obj_t * label_name = lv_label_create(cont_left, NULL);
	lv_label_set_text(label_name, "bloody41760");
	lv_obj_align(label_name, img_head, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

	lv_coord_t btn_w = lv_disp_get_hor_res(NULL) / 4;
	lv_coord_t btn_h = 61;

	static const char* btnm_map[] = { "\xef\x83\x82" "  网络设置", "\n","  \xef\x83\xa8" "  MODBUS设置",  "\n", "\xef\x81\xb1" "  报警设置", "\n", "\xef\x82\x85" "  设备信息", "\n", "" };

	lv_obj_t* btnm = lv_btnm_create(cont_left, NULL);
	lv_obj_set_size(btnm, btn_w, btn_h * 5);
	lv_btnm_set_map(btnm, btnm_map);

	static lv_style_t btnm_style;
	lv_style_copy(&btnm_style,theme_night->style.btnm.btn.tgl_pr);
	btnm_style.text.color = LV_COLOR_MAKE(0, 255, 255);
	btnm_style.body.border.width = 0;
	btnm_style.body.radius = 0;
	
	//lv_btnm_set_style(btnm, LV_BTNM_STYLE_BG,theme_night->style.btnm.bg);
	lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_REL,theme_night->style.btnm.btn.rel);
	lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_PR,&btnm_style);
	lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL, &btnm_style);
	lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR, &btnm_style);	
	
	lv_obj_set_pos(btnm, 0, 150);
	lv_btnm_set_btn_ctrl_all(btnm, LV_BTNM_CTRL_TGL_ENABLE);
	lv_btnm_set_one_toggle(btnm, true);
	
	lv_obj_set_event_cb(btnm, btnm_cb_event_handler);
	

	about_cont();
	lv_obj_set_hidden(cont_right_info,true);
	net_cont();
	lv_obj_set_hidden(cont_right_net,true);
	modbus_cont();
	lv_obj_set_hidden(cont_right_modbus,true);
	war_cont();
	lv_obj_set_hidden(cont_right_war,true);
	
}


//static void tab_cb_event_handler(lv_obj_t * cb, lv_event_t event)
//{
//	static rt_uint8_t act_num_old;
//	static rt_uint8_t act_num;
//	act_num = lv_tabview_get_tab_act(cb);
//	switch(act_num)
//	{
//		case 4:set_page();
//			break;
//	}
//}
static void tab_create(void)
{
	rt_uint8_t idx = 0;
	
	rt_pin_mode(RE_D,PIN_MODE_OUTPUT);
	rt_pin_mode(RE_CP,PIN_MODE_OUTPUT);
	rt_pin_write(RE_D,PIN_LOW);
	rt_pin_write(RE_CP,PIN_HIGH);
	
	lv_style_copy(&indic_style, &lv_style_pretty_color);
	indic_style.body.main_color = LV_COLOR_MAKE(0, 255, 255);//指示器的颜色
	indic_style.body.grad_color = indic_style.body.main_color;
	indic_style.body.padding.inner = 3;//设置指示器的高度

  static lv_style_t tab_bg_style;//tabview 背景
	lv_style_copy(&tab_bg_style, lv_obj_get_style(lv_disp_get_scr_act(NULL)));
	tab_bg_style.body.shadow.width = 0;
	tab_bg_style.body.padding.top = 0;
	tab_bg_style.body.border.width = 0;
	tab_bg_style.body.radius = 0;

  static lv_style_t btn_bg_style;//tabview 按键 背景
	lv_style_copy(&btn_bg_style, &lv_style_pretty_color);
	btn_bg_style.body.border.width = 0;
	btn_bg_style.body.radius = 0;
	btn_bg_style.body.opa = 0;

	static lv_style_t btn_tgl_pr_style;//tabview 按键 背景
	lv_style_copy(&btn_tgl_pr_style, &btn_bg_style);
	btn_tgl_pr_style.body.main_color = LV_COLOR_MAKE(0x16, 0x19, 0x18);
	btn_tgl_pr_style.body.grad_color = LV_COLOR_MAKE(0x44, 0x4c, 0x4b);
  btn_tgl_pr_style.text.color = LV_COLOR_MAKE(0, 255, 255);//字体颜色

	tabview = lv_tabview_create(lv_disp_get_scr_act(NULL), NULL);
	lv_obj_set_size(tabview, LV_HOR_RES_MAX, lv_disp_get_ver_res(NULL) - lv_obj_get_height(header));
	lv_obj_set_pos(tabview, 0, lv_obj_get_height(header));
	lv_tabview_set_btns_pos(tabview, LV_TABVIEW_BTNS_POS_BOTTOM);//设置页面选择按钮栏位于底部

	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BG, &tab_bg_style);//设置tab背景样式
	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_INDIC, &indic_style);//设置页面指示器的样式

	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_BG, &btn_bg_style);
	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_REL, &btn_bg_style);//设置按钮正常态下的松手样式
	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_PR, &btn_tgl_pr_style);//设置按钮正常态下的按下样式
	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, &btn_tgl_pr_style);//设置按钮切换态下的松手样式
	lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, &btn_tgl_pr_style);//设置按钮切换态下的按下样式

	lv_tabview_set_anim_time(tabview, 200);

	tab_page[0] = lv_tabview_add_tab(tabview, LV_SYMBOL_BATTERY_FULL);
	tab_page[1] = lv_tabview_add_tab(tabview, LV_SYMBOL_REFRESH);
	tab_page[2] = lv_tabview_add_tab(tabview, LV_SYMBOL_HOME);
	tab_page[3] = lv_tabview_add_tab(tabview, LV_SYMBOL_CHARGE);
	tab_page[4] = lv_tabview_add_tab(tabview, LV_SYMBOL_SETTINGS);


	static lv_style_t scroll_style;
	lv_style_copy(&scroll_style, lv_obj_get_style(lv_disp_get_scr_act(NULL)));
	scroll_style.body.border.width = 0;

	for(idx = 0;idx < 5;idx++)
	{
		lv_page_set_scroll_propagation(tab_page[idx], false);
		lv_page_set_sb_mode(tab_page[idx], LV_SB_MODE_OFF);
		lv_page_set_scrl_layout(tab_page[idx], LV_FIT_NONE);
		lv_page_set_style(tab_page[idx], LV_PAGE_STYLE_SCRL, &scroll_style);
	}

	
	lv_tabview_set_tab_act(tabview,0,false);
	set_page();
	apk_ph(tab_page[0]);
	apk_air(tab_page[1]);
	apk_home(tab_page[2]);
	apk_vol(tab_page[3]);
	
}
extern MODBUS_DATA MODBUSTCP_DATA;
extern struct rt_semaphore sem_modbustcp_available;
extern struct rt_semaphore sem_modbusrtu_available;
extern MODBUS_RTU_DATA  MODBUSRTU;
extern struct rt_semaphore sem_att7022eu_available;
extern total_protect_data *gtpd;
void scr_refresh_thread_entry(void* parameter)
{
	char mid_data[] = "    ";
	time_t cur_time;
	struct tm *info;
	char local_time[40] = {0};
	rt_uint32_t idx = 0;
	
	while(1)
	{
		if(rt_sem_take(&sem_temp_available,10) == RT_EOK)
		{
			sprintf(mid_data,"%d",temp_hum_data.temp);
			strcat(mid_data,"℃");
			lv_label_set_text(label_temp,mid_data); /* 设置文本 */
			lv_obj_align(label_temp, gauge_temp, LV_ALIGN_IN_BOTTOM_MID, 0, -20); /* 设置位置 */
			lv_gauge_set_value(gauge_temp, 0, temp_hum_data.temp);
			memset(mid_data,0,4);
			sprintf(mid_data,"%d",temp_hum_data.humi);
			strcat(mid_data,"%");
			lv_label_set_text(label_hum,mid_data); /* 设置文本 */
			lv_obj_align(label_hum, gauge_hum, LV_ALIGN_IN_BOTTOM_MID, 0, -20); /* 设置位置 */
			rt_sem_release(&sem_temp_available);
			lv_gauge_set_value(gauge_hum, 0, temp_hum_data.humi);	
		}
		
		cur_time = time(RT_NULL);
		info = localtime(&cur_time);//timer 的值被分解为 tm 结构，并用本地时区表示。
		strftime(local_time, 40, "%T ",info);
		lv_label_set_text(label_time_headr, local_time);
		
		if(rt_sem_take(&sem_modbustcp_available,10) == RT_EOK)
		{
			lv_chart_set_next(chart_dckw,ser_dckw,MODBUSTCP_DATA.dc_power[0]/10);
			lv_chart_set_next(chart_dcssd,ser_dcssd,MODBUSTCP_DATA.dc_power[1]/10+20);
			if(MODBUSTCP_DATA.dc_sta[0])
			{
				lv_led_off(led1);
				lv_led_on(led2);
			}
			else
			{
				lv_led_on(led1);
				lv_led_off(led2);				
			}
			switch(MODBUSTCP_DATA.dc_sta[1])
			{
				case 0:lv_led_on(led3);lv_led_off(led4);lv_led_off(led5);
					break;
				case 1:lv_led_off(led3);lv_led_on(led4);lv_led_off(led5);
					break;
				case 2:lv_led_off(led3);lv_led_off(led4);lv_led_on(led5);
					break;
				default:break;
			}
			if(MODBUSTCP_DATA.dc_sta[2])
			{
				lv_led_off(led6);
				lv_led_on(led7);
			}
			else
			{
				lv_led_on(led6);
				lv_led_off(led7);				
			}			
			
			rt_sem_release(&sem_modbustcp_available);
		}
		
		if(rt_sem_take(&sem_modbusrtu_available,10) == RT_EOK)
		{
			for(idx = 0;idx < 8;idx++)
			{
				if(MODBUSRTU.air_sta[idx])
				{
					lv_led_on(led_air[idx]); 
				}
				else
				{
					lv_led_off(led_air[idx]); 
				}
			}
			rt_sem_release(&sem_modbusrtu_available);
		}
		
		if(rt_sem_take(&sem_att7022eu_available,10) == RT_EOK)
		{
			sprintf(mid_data,"%d",gtpd->get_line_data[1].vol_value);
			lv_label_set_text(label_va_num, mid_data); /* 设置文本 */
			sprintf(mid_data,"%d",gtpd->get_line_data[2].vol_value);
			lv_label_set_text(label_vb_num, mid_data); /* 设置文本 */
			sprintf(mid_data,"%d",gtpd->get_line_data[3].vol_value);
			lv_label_set_text(label_vc_num, mid_data); /* 设置文本 */
			sprintf(mid_data,"%d",gtpd->get_line_data[1].cur_value);
			lv_label_set_text(label_i_num, mid_data); /* 设置文本 */
			lv_chart_set_next(chart_v,vol_col_i[0],gtpd->get_line_data[1].vol_value);
			lv_chart_set_next(chart_v,vol_col_i[1],gtpd->get_line_data[2].vol_value);
			lv_chart_set_next(chart_v,vol_col_i[2],gtpd->get_line_data[3].vol_value);
			lv_chart_set_next(chart_i,vol_col_i[3],gtpd->get_line_data[1].cur_value);
			rt_sem_release(&sem_att7022eu_available);
		}
		
		rt_thread_mdelay(500);
	}
}



void scr_start(void)
{
		theme_night = lv_theme_night_init(180,&FONT_SIZE12);
    lv_theme_set_current(theme_night);	
	
//		lv_img_dsc_t image_boot;
//		lv_load_img_bin_from_file(&image_boot,"/JPG/BOOT_JPG.bin"); 
		lv_obj_t *scr = lv_disp_get_scr_act(NULL);
//		lv_obj_t *image = lv_img_create(scr,NULL);
//		lv_img_set_src(image,&image_boot);
//		lv_obj_align(image,NULL,LV_ALIGN_IN_TOP_MID,0,0);
		scr = lv_obj_create(NULL, NULL);
		lv_disp_load_scr(scr);
		

		
		header_create();
		tab_create();
		rt_thread_mdelay(400);
		rt_pin_mode(LCD_BL_GPIO_NUM, 	PIN_MODE_OUTPUT);
		rt_pin_write(LCD_BL_GPIO_NUM, PIN_HIGH);
	
		//app_init_modbus_tcp();
	
	  //静态线程 - 屏幕数据刷新
    rt_thread_init(&scr_refresh_thread,              
                   "scr_refresh",                        	 
                   scr_refresh_thread_entry,           	
                   RT_NULL,                     		  	
                   &rt_scr_refresh_thread_stack[0],       
                   sizeof(rt_scr_refresh_thread_stack),  
                   scr_refresh_pro,    								 
                   20);                         		  
    rt_thread_startup(&scr_refresh_thread);
									 
}

